home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 July / macformat-026.iso / mac / Shareware City / Developers / NString 1.0 beta / Sources / Alphabet_Global.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-12  |  1.5 KB  |  78 lines  |  [TEXT/KAHL]

  1.  
  2. #define KEEP_ALPHABET_DEFINES
  3.  
  4. #include "Alphabet.h"
  5.  
  6. //________________________________________________________________________
  7.  
  8. Alphabet& Alphabet::clear (void)
  9. {
  10.     int i;
  11.     
  12.     for (i=0; i < BUFSIZE; i++)
  13.         buffer[i] = 0;                                            // clear all buffer bits
  14.         
  15.     return *this;
  16. }
  17.  
  18. //________________________________________________________________________
  19.  
  20. Alphabet& Alphabet::operator+= (const Alphabet& other)
  21. {
  22.     int i;
  23.     
  24.     for (i=0; i < BUFSIZE; i++)
  25.         buffer[i] |= other.buffer[i];                    // OR buffer bits
  26.     
  27.     return *this;
  28. }
  29.  
  30. //________________________________________________________________________
  31.  
  32. Alphabet& Alphabet::operator*= (const Alphabet& other)
  33. {
  34.     int i;
  35.     
  36.     for (i=0; i < BUFSIZE; i++)
  37.         buffer[i] &= other.buffer[i];                    // AND buffer bits
  38.     
  39.     return *this;
  40. }
  41.  
  42. //________________________________________________________________________
  43.  
  44. Alphabet& Alphabet::operator-= (const Alphabet& other)
  45. {
  46.     int i;
  47.     
  48.     for (i=0; i < BUFSIZE; i++)
  49.         buffer[i] &= ~(other.buffer[i]);                                // "substract" buffer bits
  50.     
  51.     return *this;
  52. }
  53.  
  54. //________________________________________________________________________
  55.  
  56. Alphabet& Alphabet::complement (void)
  57. {
  58.     int i;
  59.     
  60.     for (i=0; i < BUFSIZE; i++)
  61.         buffer[i] = ~(buffer[i]);                                        // invert buffer bits
  62.     
  63.     return *this;
  64. }
  65.  
  66. //________________________________________________________________________
  67.  
  68. int Alphabet::operator== (const Alphabet& other) const
  69. {
  70.     int i;
  71.     
  72.     for (i=0; i < BUFSIZE; i++)
  73.         if (buffer[i] != other.buffer[i])
  74.             return 0;
  75.             
  76.     return 1;
  77. }
  78.